﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace FYPHP
{
    public partial class ViewStaffProfile : System.Web.UI.Page
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["fyphp"].ConnectionString);


        protected void Page_Load(object sender, EventArgs e)
        {

            try
            {
                SqlCommand cmdUser;
                SqlDataReader dtrUser;
                conn.Open();

                cmdUser = new SqlCommand("Select * From Users where u_id = '1'", conn);
                dtrUser = cmdUser.ExecuteReader();
                dtrUser.Read();

                String userName = dtrUser["username"].ToString();
                String gender = dtrUser["u_gender"].ToString();
                String age = dtrUser["u_age"].ToString();
               

                string addressBeforeSplit = dtrUser["u_address"].ToString();

                string[] lines = addressBeforeSplit.Split('|');

                string address = "";

                foreach (string line in lines)
                {
                    address += " " + line;
                }
                
                String email = dtrUser["u_email"].ToString();
                String phoneNo = dtrUser["u_phone"].ToString();


                lblName.Text = userName;
                lblGender.Text = gender;
                lblAge.Text = age;
                lblAddress.Text = address;
                lblEmail.Text = email;
                lblPhoneNo.Text = phoneNo;
                

                conn.Close();
            }
            catch (SqlException ex)
            {

            }
        }

        public String return_userpicture()
        {
            SqlCommand cmdUser;
            SqlDataReader dtrUser;
            conn.Open();

            cmdUser = new SqlCommand("Select * From Users", conn);
            dtrUser = cmdUser.ExecuteReader();
            dtrUser.Read();
            String userPicture = dtrUser["u_picture"].ToString();

            conn.Close();

            return userPicture;

        }

        protected void EditProfile_Click(object sender, EventArgs e)
        {
            Response.Redirect("EditProfile.aspx");



        }

        protected void EditProfile_Click1(object sender, EventArgs e)
        {
            Response.Redirect("EditStaffProfile.aspx");
        }

   

  
    }
}